//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#ifndef __ELASTOS_DDK_H__
#define __ELASTOS_DDK_H__

#define _NO_INCLIST
#include <eltypes.h>
#include <elasys_server.h>
#include <interlocked.h>

#include <aura.h>

#define PAGE_SIZE   4096
#define g_pDefaultScheduleClass NULL
#define g_uDefaultSchedulePolicy NULL

//#ifdef __cplusplus
//extern "C" int __cdecl kprintf (const char *, ...);
//#else
//int    __cdecl kprintf (const char *, ...);
//#endif

#define kprintf Aura_printf

extern Elastos::UInt32 DzMillisecondsToTicks(Elastos::UInt32 milliseconds);
extern Elastos::UInt32 DzTicksToMilliseconds(Elastos::UInt32 time);
extern Elastos::UInt32 DzGetElapsedTicks();


extern Elastos::ECode DzFindService(const wchar_t *pwszName, PInterface *ppObj);

typedef Elastos::Int32 (__cdecl *threadroutine_t)(void *);

extern Elastos::ECode DzCreateKernelThread(
        threadroutine_t threadroutine,
        void *pvArg,
        Elastos::UInt32 dwFlags,
        ThreadPriorityRank priorityRank,
        IThread **ppThread);

extern Elastos::ECode DzCreateEventObj(
         Elastos::Boolean manualReset,
         Elastos::EventState initialState,
         IEvent **ppEvent);

extern IThread *CreateSystemThread(
        threadroutine_t threadroutine,
        void *pvParameter,
        void *pScheduleClass,
        uint_t uSchedulePolicy);

#define AURA_LOCK(lock)   do {AuraCriticalSection_Enter(lock); }while(0)
#define AURA_UNLOCK(lock) do {AuraCriticalSection_Leave(lock); }while(0)
#define AURA_SLEEP(ms)    do { \
            Aura_WaitResult wr; \
            AuraThread_Sleep(ms, &wr); \
        }while(0)

#endif

